# -*- coding: utf-8 -*-

# Copyright (c) Huoty, All rights reserved
# Author: Huoty <sudohuoty@163.com>
# CreateTime: 2020-10-30 18:18:31

import time
import signal
import threading


def register_signal_handler():

    def handle_signal(signum, frame):
        print("Received signal {}, current thread: {}".format(signum, threading.currentThread().name))

    signal.signal(signal.SIGHUP, handle_signal)
    signal.signal(signal.SIGINT, handle_signal)
    signal.signal(signal.SIGTERM, handle_signal)



def worker():
    while True:
        print("-" * 10, threading.currentThread().name)
        time.sleep(1)


register_signal_handler()

threading.Thread(target=worker).start()
threading.Thread(target=worker).start()
threading.Thread(target=worker).start()
threading.Thread(target=worker).start()

# register_signal_handler()

time.sleep(10)
